/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.pacis.shca.domain.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author solriver
 */
@Entity
@Table(name = "grupo_familiar", catalog = "bdshca")
@NamedQueries({
    @NamedQuery(name = "GrupoFamiliar.findAll", query = "SELECT g FROM GrupoFamiliar g"),
    @NamedQuery(name = "GrupoFamiliar.findByIdGrupoFamiliar", query = "SELECT g FROM GrupoFamiliar g WHERE g.idGrupoFamiliar = :idGrupoFamiliar"),
    @NamedQuery(name = "GrupoFamiliar.findByGruIdioma", query = "SELECT g FROM GrupoFamiliar g WHERE g.gruIdioma = :gruIdioma")})
public class FamilyGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_grupo_familiar")
    private Integer id;
    @Column(name = "gru_idioma")
    private String language;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "familyGroup")
    private FamilyRecord familyRecord;
    @JoinColumn(name = "gru_id_jefe_familia", referencedColumnName = "id_miembro")
    @ManyToOne(optional = false)
    private Member headHousehold;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "familyGroup")
    private List<ResidenceRecord> residenceRecords;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "familyGroup")
    private List<GroupRecord> groupRecords;

    public FamilyGroup() {
    }

    public FamilyGroup(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public FamilyRecord getFamilyRecord() {
        return familyRecord;
    }

    public void setFamilyRecord(FamilyRecord familyRecord) {
        this.familyRecord = familyRecord;
    }

    public Member getHeadHousehold() {
        return headHousehold;
    }

    public void setHeadHousehold(Member headHousehold) {
        this.headHousehold = headHousehold;
    }

    public List<ResidenceRecord> getResidenceRecords() {
        return residenceRecords;
    }

    public void setResidenceRecords(List<ResidenceRecord> residenceRecords) {
        this.residenceRecords = residenceRecords;
    }

    public List<GroupRecord> getGroupRecords() {
        return groupRecords;
    }

    public void setGroupRecords(List<GroupRecord> groupRecords) {
        this.groupRecords = groupRecords;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FamilyGroup)) {
            return false;
        }
        FamilyGroup other = (FamilyGroup) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.pacis.shca.domain.entity.FamilyGroup[ id=" + id + " ]";
    }
    
}
